﻿package blob.mechanisms
{
    import blob.characters.*;
    import blob.levelstates.*;
    import org.flixel.*;

    public class Button extends FlxSprite implements Mechanism
    {
        private var img:Class;
        private var activated:Boolean;
        private var mech:Mechanism;
        private var activateSize:int;
        private var activatingCharacter:Character;

        public function Button(param1:Number, param2:Number, param3:Mechanism, param4:int)
        {
            super(param1, param2);
            this.activated = false;
            this.mech = param3;
            this.activateSize = param4;
            addAnimation("idle", [0], 0, false);
            addAnimation("active", [1], 0, false);
            immovable = true;
            allowCollisions = ANY;
            return;
        }// end function

        public function activate(param1:Character) : void
        {
            var _loc_2:PlayState = null;
            if (param1.size() >= this.activateSize && !this.activated && isTouching(UP))
            {
                _loc_2 = FlxG.state as PlayState;
                _loc_2.buttonPairs[this] = param1;
                play("active");
                this.activated = true;
                this.mech.activate(param1);
            }
            return;
        }// end function

        override public function update() : void
        {
            return;
        }// end function

        public function deactivate() : void
        {
            play("idle");
            this.mech.activate(this.activatingCharacter);
            this.activated = false;
            return;
        }// end function

        public function isActivated() : Boolean
        {
            return this.activated;
        }// end function

        public function toggle() : void
        {
            return;
        }// end function

    }
}
